package com.carhome.ui.base;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.support.v4.app.FragmentActivity;

/**
 * activity控制类
 */
public class FragmentActivityCollector extends FragmentActivity {
	public static List<Activity> activities = new ArrayList<Activity>();
	
	/**
	 * 添加activity到activities集合
	 * @param activity
	 */
	public static void addActivity(Activity activity)
	{
		activities.add(activity);
	}
	/**
	 * 将activity从集合中移除
	 * @param activity
	 */
	public static void removeActivity(Activity activity)
	{
		activities.remove(activity);
	}
	
	/**
	 * 结束所有的activity
	 */
	public static void finishAll()
	{
		for (Activity activity : activities) {
			if (!activity.isFinishing()) {
				activity.finish();
			}
		}
	}
}
